scp interview questions
Top scp frequently asked interview questions
I love WinSCP for Windows. What are the best equivalent softwares for linux?
I tried to use sshfs to mount the remote file system on my local machine, but it is not as user friendly as simply launching a GUI, plus it seems to require root access on the client machine, which is not very convenient.
Of course command line tools such as scp are possible, but I am looking for a simple GUI.
Source: (StackOverflow)
I have a text file on my local machine that is generated by a python script run daily in cron. I would like to add a bit of code to have that file sent securely to my server over ssh. Help.
Source: (StackOverflow)
I need to copy all the .class files from server to local with all dir reserved. e.g. server:/usr/some/unknown/number/of/sub/folders/me.class
will be /usr/project/backup/some/unknown/number/of/sub/folders/me.class
the problem is, there are many other useless files such as .svn-base files that i don't want. how can i filter them so I only scp
.class files?
Source: (StackOverflow)
I have some n number of files in a directory on my unix system. Is there a way to write a shellscript that will transfer all those files via scp to a specified remote system. I'll specify the password within the script, so that I don't have to enter it for each file.
Source: (StackOverflow)
I have two users in Fedora:
(i) Wani
(ii) root (quite obvious!)
My contents of .bashrc of user Wani are:
# .bashrc
echo "Hello"
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
Now after logging into root, I type the following commands:
[root@Dell Wani]#touch try.txt
[root@Dell Wani]#service sshd start
[root@Dell Wani]#scp try.txt Wani@localhost:~/
Wani@localhost's password:
Hello
[root@Dell Wani]#
Now I log into Wani, and type:
[Wani@Dell ~]$ cat try.txt
cat: try.txt: No such file or directory
[Wani@Dell ~]$
Now I again log into root and type the same command with -v:
[root@Dell Wani]# scp -v morph.log Wani@localhost:
Executing: program /usr/bin/ssh host localhost, user Wani, command scp -v -t -- .
OpenSSH_5.6p1, OpenSSL 1.0.0j-fips 10 May 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to localhost [127.0.0.1] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.6
debug1: match: OpenSSH_5.6 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.6
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'localhost' is known and matches the RSA host key.
debug1: Found key in /root/.ssh/known_hosts:2
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi- with-mic,password
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure. Minor code may provide more information
Credentials cache file '/tmp/krb5cc_0' not found
debug1: Unspecified GSS failure. Minor code may provide more information
Credentials cache file '/tmp/krb5cc_0' not found
debug1: Unspecified GSS failure. Minor code may provide more information
debug1: Unspecified GSS failure. Minor code may provide more information
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/id_rsa
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Next authentication method: password
Wani@localhost's password:
debug1: Authentication succeeded (password).
Authenticated to localhost ([127.0.0.1]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env XMODIFIERS = @im=none
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending command: scp -v -t -- .
Hello
[root@Dell Wani]# debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
Transferred: sent 1664, received 1976 bytes, in 0.1 seconds
Bytes per second: sent 22961.5, received 27266.8
debug1: Exit status 0
(And After I press Enter)
[root@Dell Wani]#
Can anyone please shed some light as to what exactly happened here? Why did the file not get copied to Wani from root?
Source: (StackOverflow)
What is the best method of performing an scp transfer via the Java programming language? It seems I may be able to perform this via JSSE, JSch or the bouncy castle java libraries. None of these solutions seem to have an easy answer.
Source: (StackOverflow)
I am not sure whether it is possible to scp
a folder from remote to local, but still I am left with no other options. I use ssh to log into my server and from there I would like to copy the folder foo
to home/user/Desktop
(my local). Is there any command so that I can do this?
Source: (StackOverflow)
I need to reinstall one of ours servers, and as a precaution, I want to move /home
, /etc
, /opt
, and /Services
to backup server.
However, I have a problem: because of plenty of symbolic links a lot of files are copied multiple times.
Is it possible to make scp
ignore the symbolic links (or actually to copy link as a link not as a directory or file)? If not, is there another way to do it?
Source: (StackOverflow)
I'm new to linux, I want to copy a file from remote to local system... now I'm using scp command in linux system.. I have some folders or files names are with spaces, when I try to copy that file, it shows the error message: "No such file or directory"
I tried:
scp ael5105@192.168.0.200:'/home/5105/test/gg/Untitled Folder/a/qy.jpg' /var/www/try/
I saw the some reference online but I don't understand perfectly, can any one help on this?
how can I escape spaces in file name or directory names during copying...
Source: (StackOverflow)
I am wondering if scp will create the target folder if it does not exist on the remote server. For example, would this work?
scp -r /data/install/somefolder user@ftpserver.com:/data/install/somefolder
Here the folder /data/install/somefolder
doesn't exist on ftp server, so would this command create it?
N.B. I have read about rsync but am not really sure how it works or how to use it yet.
Source: (StackOverflow)
When fetching or pulling from git repositories, or cloning a repository, I get to this point:
remote: Counting objects: 6666, done.
remote: Compressing objects: 100% (5941/5941), done.
Receiving objects: 23% (1534/6460), 11.68 MiB | 23 KiB/s
And it hangs. The 23%/number of objects isn't a given, it ranges from single digits to up to the 60s, it seems. Also the speed for download listed freezes -- it's not like it slowly crawls down towards zero.
The guy I sit next to has no issues, so it's not a router problem. We use beanstalk for our work repositories, but I have the issue from beanstalk and github (although occaisonally it seems a github one will finish).
The problem has only seemed to crop up since upgrading to Mountain Lion and updating Xcode. I've wiped git (including XCode's) and tried installing it with homebrew. That didn't work, so I removed it and tried with their provided Mac installation package which also didn't fix the issue.
Beanstalk provides SSH urls for the git repository, but I've had no issues with connecting via SCP or SSH to servers that I've done work on.
This is killing my workflow so any help would be much appreciated!
Source: (StackOverflow)
I want to use scp command to copy a local file to remote server, but I get an error message after input the password of user in remote server.
~]$ scp gitadmin.pub git@123.150.207.18:
git@123.150.207.18's password:
bash: scp: command not found
lost connection
I checked on server using the git user and it seems the scp command can be found and openssh-clinets were installed too.
git@... ~]$ scp
usage: scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
[-l limit] [-o ssh_option] [-P port] [-S program]
[[user@]host1:]file1 ... [[user@]host2:]file2
git@... ~]$ su root
......
root@... ~]# yum info openssh-clients
Loaded plugins: product-id, subscription-manager
Updating Red Hat repositories.
Installed Packages
Name : openssh-clients
Arch : x86_64
Version : 5.3p1
Release : 52.el6
Size : 1.0 M
Repo : installed
From repo : anaconda-RedHatEnterpriseLinux-201105101844.x86_64
Summary : An open source SSH client applications
URL : http://www.openssh.com/portable.html
License : BSD
Description : OpenSSH is a free version of SSH (Secure SHell), a program for
: logging into and executing commands on a remote machine. This
: package includes the clients necessary to make encrypted
: connections to SSH servers.
I'm confused for the situation. Did I missing some configuration on server? (We are using RHEL6 as server.)
It's my fault in path setting.
I added 'custom.sh' in /etc/profile.d and added following lines in it to add /usr/local/node/bin directory to PATH.
export PATH="/usr/local/node/bin:$PATH"
But the format is wrong. I removed the pair of '"' and it works OK now. It should be:
export PATH=$PATH:/usr/local/node/bin
A probe mistake...^_^
Source: (StackOverflow)
What scp
arguments should I use to download a file from an Amazon EC2 instance to local storage?
Source: (StackOverflow)
I was copying some files using scp and i don't want to overwrite the already present files.
If i was using cp command, i think this can be done using cp -n.
Is there a similar option for scp, i went through the documentation of SCP and there seems to be no such option.
Is rsync or sftp the way to go solve this problem?
Addition Info:
OS: Ubuntu 12.04
Source: (StackOverflow)
There is a certain ubuntu 10.04 server where if I ssh a file onto it from any server that is outside the office where this server is (meaning any of use scp-ing onto this server through LAN from within this server always works for some reason), then scp-ing fails for any file over 2112 kB in size, and is stuck at 2112 kB.
So
scp -vvv /home/attila-szeremi/aszeremi.tar.gz attila@server.hu:~/aszeremi.tar.gz
shows something like 1% 2112KB 909.2KB/s - stalled -
dynamically at the end, where the KB/s becomes lower and lower.
Does anyone know what may be causing this and how I can fix it?
What I have tried so far:
- Limiting the speed with scp -l 2000. It just made the file sending slower, and at 2112 kB it got stuck again.
- Enabling compresison with -C. It was still stalled at the same size.
Source: (StackOverflow)